Xbasic

usps_state_from_zip Function

Syntax

State as C = usps_state_from_zip(C zip5 )

Arguments

State

The name of the state containing the specified ZIP code.

zip5

A 5 or 9 digit ZIP code. The function truncates 9 digit codes to 5 digits.

Description

Contacts the USPS web site and looks up the state for the specified 5 digit zip code.

Discussion

The USPS_State_From_ZIP() function contacts the USPS web site and looks up the state containing the specified ZIP code. It then returns the state that contains the specified ZIP code. Note : Use of this function requires an active Internet connection. ZIP codes are used by the US Postal Service (USPS) for addressing mail in the United States.

Example

? usps_state_from_zip("01803") 
= "MA" 

? usps_state_from_zip("12345") 
= "NY"